﻿using ShareFrame.Entity;
using ShareFrame.Entity.Base_Manage;
using ShareFrame.Entity.DTO;
using ShareFrame.Util;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ShareFrame.IBusiness.Base_Manage
{
    public interface IBase_UserBusiness
    {
        /// <summary>
        /// 根据单一条件获取分页结果集
        /// </summary>
        /// <param name="input">传入条件参数</param>
        /// <returns></returns>
        Task<PageResult<Base_UserDTO>> GetDataListAsync(PageInput<Base_UsersInputDTO> input);

        Task<List<SelectOption>> GetOptionListAsync(OptionListInputDTO input);

        /// <summary>
        /// 根据传入Id获取对应实体信息
        /// </summary>
        /// <param name="id">实体唯一编号</param>
        /// <returns></returns>
        Task<Base_UserDTO> GetTheDataAsync(string id);


        Task AddDataAsync(UserEditInputDTO input);


        Task UpdateDataAsync(UserEditInputDTO input);


        /// <summary>
        /// 根据传入的条件组 更新对应的值
        /// </summary>
        /// <param name="basedbOptions">传入的数据库连接</param>
        /// <param name="input">传入的条件信息</param>
        /// <returns></returns>
        Task<int> UpdateDataAsyncByConditions(BaseDbOption basedbOptions, Base_UserUpdateUserAvatar input);

        /// <summary>
        /// 批量单列更新方法
        /// </summary>
        /// <typeparam name="T">更新列数值类型</typeparam>
        /// <param name="basedbOptions">数据库连接字符串对象</param>
        /// <param name="columnName">更新列名</param>
        /// <param name="upValue">更新值</param>
        /// <param name="ids">ID集合</param>
        /// <returns></returns>
        Task UpdateDataAsync<T>(BaseDbOption basedbOptions, string columnName, T upValue, List<string> ids);
        Task DeleteDataAsync(List<string> ids);
    }

    [Map(typeof(Base_User))]
    public class UserEditInputDTO : Base_User
    {
        public string newPwd { get; set; }
        public List<string> RoleIdList { get; set; }
    }

    public class Base_UsersInputDTO
    {
        public bool all { get; set; }
        public string userId { get; set; }
        public string keyword { get; set; }
    }
}